package com.bargate.domain.spring.expression.value;

import com.bargate.domain.spring.expression.Storm;
import org.springframework.beans.factory.annotation.Value;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: EAD-MASTER
 * Date: 28/09/2010
 * Time: 23:01:02
 * To change this template use File | Settings | File Templates.
 */
public class MapSelectionOperations {

    /* Selecting all storms with wind velocity over 100 */
    @Value("#{StormsMap.?[value.maxWindVelocity > 100]}")
    private Map<String, Storm> mapOfStorms;

    public Map<String, Storm> getMapOfStorms() {
        return mapOfStorms;
    }

    @Value("#{NumbersMap[3]}")
    private Integer singleNumber;

    public Integer getSingleNumber() {
        return singleNumber;
    }
/* Selecting the last found value in map */
    @Value("#{StormsMap.^[!value.Harmful]}")
    private Map<String, Storm> mapOfHarmfulStorms;

    public Map<String, Storm> getMapOfHarmfulStorms() {
        return mapOfHarmfulStorms;
    }
    @Value("#{NumbersMap.$[value < 15]}")
    private  Map<Integer,Integer> biggerThen25;

    public Integer getBiggerThen25() {
        for (Integer integer : biggerThen25.keySet()) {
        return biggerThen25.get(integer);
        }
       return null;
    }

    @Value("#{StormsMap.$[!value.Harmful]}")
    private Map<String, Storm> lastFastStorm;

    @SuppressWarnings({"LoopStatementThatDoesntLoop"})
    public Storm getLastFastStorm() {
        for (String s : lastFastStorm.keySet()) {
            return lastFastStorm.get(s);
        }
        return null;
    }
}
